1. Field of the Invention
This invention relates to the field of object-oriented computer graphics and imaging.
2. Background Art
In computer graphics applications there is a technique for combining two images known as xe2x80x9ccompositingxe2x80x9d. One example of compositing is the blending of a new screen object of one color with an existing screen object of another color. This color blend is accomplished using a well known compositing technique known as alpha compositing, such as described by T. Porter and T. Duff, xe2x80x9cCompositing Digital Imagesxe2x80x9d, SIGGRAPH 84, pp. 253-259. A problem with current schemes for providing compositing in computer systems is a difficulty in adding different compositing techniques. Currently, available compositing schemes are hard coded algorithms and are often tied to specific hardware implementations. This discourages or prevents the addition of customized compositing schemes.
The present invention provides a method and apparatus that permits the introduction of customized compositing techniques into an application by a developer. A Composite interface and a CompositeContext interface are defined. Custom compositing operations can be defined by implementing these interfaces. A Composite object provides a CompositeContext object that holds the state and performs the compositing work. Multiple CompositeContext objects can be created from one Composite object to maintain separate states in a multi-threaded environment.
An object implementing the Composite interface can be set as rendering state on a graphics object that provides rendering methods. This allows arbitrary compositing rules to be used by a developer. In one implementation of the Composite and CompositeContext interfaces, an AlphaComposite class is defined. The AlphaComposite class implements common compositing rules, such as defined by Porter and Duff, for combining source and destination pixels to achieve blending and transparency effects with graphics and images.